<template>
  <div class="interview-feedback-container">
    <el-header class="header">
      <div class="logo">职途导师</div>
      <el-menu 
        mode="horizontal" 
        :default-active="activeMenu" 
        class="nav-menu"
        router
      >
        <el-menu-item index="/home">主页</el-menu-item>
        <el-menu-item index="/pending-interviews">待面试列表</el-menu-item>
        <el-menu-item index="/interview-history">面试历史记录</el-menu-item>
      </el-menu>
      <div class="user-info">
        <el-dropdown>
          <span class="user-dropdown">
            <el-avatar :size="32" src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" />
            <span class="username">用户名</span>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item>个人中心</el-dropdown-item>
              <el-dropdown-item>设置</el-dropdown-item>
              <el-dropdown-item divided @click="handleLogout">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </el-header>
    
    <el-main class="main-content">
      <div class="page-header">
        <h2 class="page-title">面试反馈</h2>
        <el-button type="primary" @click="goBack">返回</el-button>
      </div>
      
      <el-card v-loading="loading" class="feedback-card">
        <template v-if="feedback">
          <h3>{{ feedback.position }} - {{ feedback.company }}</h3>
          <p class="interview-date">面试日期：{{ feedback.date }}</p>
          
          <el-divider />
          
          <div class="feedback-content">
            <h4>面试官反馈</h4>
            <div class="feedback-item">
              <h5>技术能力</h5>
              <el-rate v-model="feedback.technicalScore" disabled show-score text-color="#ff9900" />
              <p>{{ feedback.technicalFeedback }}</p>
            </div>
            
            <div class="feedback-item">
              <h5>沟通能力</h5>
              <el-rate v-model="feedback.communicationScore" disabled show-score text-color="#ff9900" />
              <p>{{ feedback.communicationFeedback }}</p>
            </div>
            
            <div class="feedback-item">
              <h5>问题解决能力</h5>
              <el-rate v-model="feedback.problemSolvingScore" disabled show-score text-color="#ff9900" />
              <p>{{ feedback.problemSolvingFeedback }}</p>
            </div>
            
            <div class="feedback-item">
              <h5>总体评价</h5>
              <p>{{ feedback.overallFeedback }}</p>
            </div>
            
            <div class="feedback-item">
              <h5>改进建议</h5>
              <p>{{ feedback.suggestions }}</p>
            </div>
          </div>
        </template>
        <el-empty v-else description="未找到面试反馈" />
      </el-card>
    </el-main>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';

const route = useRoute();
const router = useRouter();
const activeMenu = ref('/interview-history');
const loading = ref(true);
const feedback = ref(null);

// 模拟数据
const mockFeedback = {
  id: 1,
  position: 'Vue开发工程师',
  company: '阿里巴巴',
  date: '2023-11-20',
  technicalScore: 4.5,
  technicalFeedback: '候选人展示了扎实的Vue技术基础，熟悉Vue的核心概念和工作原理。在组件设计和状态管理方面有很好的理解。可以更深入了解Vue性能优化的方法。',
  communicationScore: 4,
  communicationFeedback: '表达清晰，能够准确描述技术概念和解决方案。在面对压力问题时保持冷静和逻辑性。',
  problemSolvingScore: 4.2,
  problemSolvingFeedback: '解决问题的思路清晰，能够迅速分析问题并提出合理的解决方案。在复杂场景下可以进一步提高分析能力。',
  overallFeedback: '整体表现优秀，技术基础扎实，有丰富的项目经验。团队协作意识强，能够很好地融入团队。',
  suggestions: '建议进一步学习Vue3的新特性和组合式API，提高在性能优化方面的经验。可以尝试参与更多开源项目，拓展技术视野。'
};

// 返回上一页
const goBack = () => {
  router.back();
};

// 退出登录
const handleLogout = () => {
  localStorage.removeItem('isLoggedIn');
  router.push('/login');
};

onMounted(() => {
  const interviewId = route.params.id;
  
  // 模拟API请求
  setTimeout(() => {
    feedback.value = mockFeedback;
    loading.value = false;
  }, 1000);
});
</script>

<style scoped>
.interview-feedback-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  align-items: center;
  padding: 0 20px;
  background-color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 999;
}

.logo {
  font-size: 22px;
  font-weight: bold;
  color: #1890ff;
  margin-right: 40px;
}

.nav-menu {
  flex: 1;
  border-bottom: none;
}

.user-info {
  margin-left: 20px;
}

.user-dropdown {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.username {
  margin-left: 8px;
}

.main-content {
  padding: 20px;
  background-color: #f5f7fa;
  flex: 1;
  overflow-y: auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-title {
  margin: 0;
  font-size: 20px;
  color: #333;
}

.feedback-card {
  margin-bottom: 20px;
}

.feedback-card h3 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 18px;
  color: #333;
}

.interview-date {
  color: #666;
  margin-bottom: 20px;
}

.feedback-content h4 {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 16px;
  color: #333;
}

.feedback-item {
  margin-bottom: 20px;
}

.feedback-item h5 {
  margin-top: 0;
  margin-bottom: 10px;
  font-size: 14px;
  color: #333;
}

.feedback-item p {
  margin: 10px 0 0;
  line-height: 1.6;
  color: #666;
}
</style> 